<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h2>Promise 提取为方法</h2>
    <script>
      // 调用方法,即可获取Promise对象
      // delay 秒为单位
        function fun(num){
          return new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve(num)
          }, num*1000)
        })
        }
       fun('1').then(res=>{
        console.log('res1',res);
         return fun('2')
       }).then(res=>{
        console.log('res2',res);
        return fun('3')
       }).then(res=>{
        console.log('res3',res);
       })

    </script>
  </body>
</html>
